<template>
  <div class="list-table">
    <div class="area-header">
      <span class="area-header-title">{{ $t('基金管理人填报情况') }}</span>
    </div>
    <el-form ref="queryForm" :model="queryParams" :inline="true">
      <el-form-item :label="$t('管理人名称')" prop="bfName">
        <el-input v-model="queryParams.bfName" :placeholder="$t('管理人名称')" @keyup.enter.native="queryHandle" />
      </el-form-item>
      <el-form-item :label="$t('年份')" prop="reportYear">
        <DatePicker
          v-model="queryParams.reportYear"
          type="year"
          format="yyyy"
          value-format="yyyy"
          :placeholder="$t('年份')"
          @keyup.enter.native="queryHandle"
        />
      </el-form-item>
      <el-form-item :label="$t('报告期')" prop="reportType">
        <el-select v-model="queryParams.reportType" :clearable="true" @keyup.enter.native="queryHandle">
          <el-option
            v-for="dict in reportTypeOption"
            :key="dict.id"
            :label="$t(dict.dictLabel)"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('状态')" prop="applyStatus">
        <el-select v-model="queryParams.applyStatus" :clearable="true" @keyup.enter.native="queryHandle">
          <el-option
            v-for="dict in applyStatusOptions"
            :key="dict.id"
            :label="$t(dict.dictLabel)"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t("搜索") }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t("重置") }}</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" tooltip-effect="darkTable" :data="dataList" border>
      <el-table-column :label="$t('序号')" type="index" align="center" width="50">
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('管理人名称')" align="left" prop="bfName" show-overflow-tooltip min-width="180">
        <template slot-scope="scope">
          {{ scope.row.bfName }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('年份')" align="center" prop="reportYear" show-overflow-tooltip min-width="120" />
      <el-table-column :label="$t('报告期')" align="center" prop="reportTypeLabel" show-overflow-tooltip min-width="120" />
      <el-table-column :label="$t('创建时间')" align="center" prop="createTime" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('状态')" align="center" prop="applyStatus" :formatter="formatStatus" show-overflow-tooltip min-width="120" />
      <!--<el-table-column :label="$t('提交时间')" align="center" prop="submitTime" show-overflow-tooltip min-width="120">-->
      <!--  <template slot-scope="scope">-->
      <!--    <span v-if="scope.row.submitStatus === '已审核'">{{ parseTime(scope.row.updateTime) }}</span>-->
      <!--  </template>-->
      <!--</el-table-column>-->
      <!--<el-table-column :label="$t('审核状态')" align="center" prop="submitStatus" show-overflow-tooltip min-width="120">-->
      <!--  <template slot-scope="scope">-->
      <!--    <span v-if="isEmpty(scope.row.submitStatus)">{{ $t('未审核') }}</span>-->
      <!--  </template>-->
      <!--</el-table-column>-->
      <!--<el-table-column fixed="right" :label="$t('审批状态')" show-overflow-tooltip align="center" width="120">-->
      <!--  <template slot-scope="scope">-->
      <!--    <span></span>-->
      <!--  </template>-->
      <!--</el-table-column>-->
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getDictOption, getList } from '@/api/bf/report/reportPeriodStatus'
export default {
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 事项申请表格数据
      dataList: [],
      // 查询参数
      queryParams: {
        bfName: undefined,
        reportYear: undefined,
        reportType: undefined,
        pageNum: 1,
        pageSize: 10
      },
      reportTypeOption: [],
      applyStatusOptions: []
    }
  },
  created() {
    getDictOption('report_type').then(response => {
      this.reportTypeOption = response.data.data
    })
    getDictOption('apply_status').then(response => {
      this.applyStatusOptions = response.data.data
    })
    this.getList()
  },
  methods: {
    /** 查询事项申请列表 */
    getList() {
      this.loading = true
      getList(this.queryParams).then(res => {
        const response = res.data
        this.dataList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    /** 搜索按钮操作 */
    queryHandle() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.reportType = undefined
      this.queryParams.reportYear = undefined
      this.resetForm('queryForm')
      this.queryHandle()
    },
    formatStatus(row) {
      return this.selectDictLabel(this.applyStatusOptions, row.applyStatus)
    }
  }
}
</script>
